package de.bensoft.jrail.client.com;

import gnu.io.CommPortIdentifier;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

public class CommunicationHelper {

	public String[] getAvailablePorts() {
		List<String> ret = new ArrayList<String>();
		@SuppressWarnings("unchecked")
		Enumeration<CommPortIdentifier> cpis = CommPortIdentifier.getPortIdentifiers();
		
		while(cpis.hasMoreElements()) {
			CommPortIdentifier i = cpis.nextElement();
			ret.add(i.getName());
		}
		
		String[] r1 = new String[ret.size()];
		return ret.toArray(r1);
	}
}
